<?php
    // 登录 后端

    // 接收前端传过来的信息
    $username = $_POST['username'];
    $password = $_POST['password'];
    $nickname = $_POST['nickname'];
    

    // 验证用户名是否存在
    $link = mysqli_connect('localhost','root','root','helianna');

    $sql= "SELECT * FROM `user` WHERE `username`='$username' AND `password`='$password'";

    $res = mysqli_query($link,$sql);

    $data = mysqli_fetch_all($res,MYSQLI_ASSOC);


    if(count($data)){
        $arr = [
            "message" => "登录成功",
            "code" => 1,
            "info" => $data
        ];
    }else{
        $arr = [
            "message" => "登录失败,没有此用户名,请确认是否填写正确",
            "code" => 0
        ];
    }

    echo json_encode($arr);

?>